package com.yurun.controller;

import com.yurun.entity.Article;
import com.yurun.model.vo.PageResult;
import com.yurun.model.vo.Result;
import com.yurun.model.vo.article.ArticleInfoArticleshow;
import com.yurun.model.vo.article.ArticleInfoHomeshow;
import com.yurun.service.ArticleService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class ArticleController {
    @Autowired
    ArticleService articleService;
    /**
     * @Description: 前台-文章信息概览
     * @Param: pageNum
     * @return: com.yurun.model.vo.Result
     * @Author: JimmyYao
     * @Date: 2022/2/9
     */
    @ApiOperation(value = "文章前台信息",notes = "文章前台信息")    // swagger2 注入代码
    @GetMapping("articleinfohomeshow")
    public Result getArticleInfoHomeshowList(@RequestParam(defaultValue = "1") Integer pageNum){
        PageResult<ArticleInfoHomeshow> object=articleService.getArticleInfoHomeshowList(pageNum);
        return Result.ok("首页文章信息",object);
    }
    /**
     * @Description: 前台-第二页面-文章信息概览
     * @Param: pageNum
     * @return: com.yurun.model.vo.Result
     * @Author: JimmyYao
     * @Date: 2022/2/9
     */
    @GetMapping("articleInfoarticleshowlist")
    public Result getArticleInfoArticleshowList(@RequestParam(defaultValue = "1") Integer pageNum){
        PageResult<ArticleInfoArticleshow> object=articleService.getArticleInfoArticleshowList(pageNum);
        return Result.ok("第二级文章信息",object);
    }
    /**
     * @Description: 前台-第二页面-通过分类-文章信息概览
     * @Param: category_id
     * @return: com.yurun.model.vo.Result
     * @Author: JimmyYao
     * @Date: 2022/2/9
     */
    @GetMapping("articleInfoarticleshowlistbycategory")
    public Result getArticleListByCategory(@RequestParam Integer category_id){
        List<ArticleInfoArticleshow> object=articleService.getArticleListByCategory(category_id);
        return Result.ok("通过类别获取第二级文章信息",object);
    }
    /**
     * @Description: 前台-第三页面-通过文章ID-文章详细内容
     * @Param: id
     * @return: com.yurun.model.vo.Result
     * @Author: JimmyYao
     * @Date: 2022/2/9
     */
    @GetMapping("article")
    public Result getArticleById(@RequestParam Integer id){
        Article object=articleService.getArticleById(id);
        return Result.ok("文章内容",object);
    }
}
